import socket
if __name__ == '__main__':
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    try:
        s.connect(('8.8.8.8', 80))
        lip = s.getsockname()[0]
    finally:
        s.close()
    print(lip)
